//
//  CallMeViewController.m
//  NewMusic
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "CallMeViewController.h"
#import "EmailViewController.h"
#import "CallMeLFTableViewCell.h"
#import "HQCallMeTableViewCell.h"
#import "CallMeHeadView.h"
@interface CallMeViewController ()<UITableViewDataSource, UITableViewDelegate, HQNiceAndEmail>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *callArray;
@end

@implementation CallMeViewController
- (void)dealloc
{
    [_tableView release];
    [_callArray release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 创建navItem
    [self creatNav];
    // 创建tableView
    [self creatTableView];
    // 创建头视图
    [self tableViewHeadView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (0 == section)
    {
        return 1;
    }
    return self.callArray.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (0 == indexPath.section)
    {
        CallMeLFTableViewCell *cellC = [self.tableView dequeueReusableCellWithIdentifier:@"cellC"];
        cellC.delegate = self;
        cellC.selectionStyle = UITableViewCellSelectionStyleNone;
        cellC.backgroundColor = [UIColor clearColor];
        return cellC;
    } else {
        HQCallMeTableViewCell *cellH = [self.tableView dequeueReusableCellWithIdentifier:@"cellH"];
        cellH.backgroundColor = [UIColor clearColor];
        cellH.selectionStyle = UITableViewCellSelectionStyleNone;
        cellH.labelName = self.callArray[indexPath.row];
        return cellH;
    }
}
// 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (1 == indexPath.section)
    {
        
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (1 == indexPath.section)
    {
        return 60;
    }
    return 140;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (0 == section)
    {
        return 0;
    }
    return 20;
}
// 头视图变色
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    view.tintColor = [UIColor clearColor];
}
- (void)creatTableView
{
    self.callArray = [NSArray arrayWithObjects:@"欢迎页", @"分享应用", nil];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 375, 667) style:UITableViewStylePlain];
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[CallMeLFTableViewCell class] forCellReuseIdentifier:@"cellC"];
    [self.tableView registerClass:[HQCallMeTableViewCell class] forCellReuseIdentifier:@"cellH"];
    [self.view addSubview:self.tableView];
    [_tableView release];
}
- (void)creatNav
{
    self.navigationItem.title = @"关于Fox Music";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(barLeft)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithRed:210 / 255.0 green:210 / 255.0 blue:210 / 255.0 alpha:1.0];
}
- (void)barLeft
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
// 发送邮件界面
- (void)NiceCallAndToEmail:(NSInteger)num
{
    EmailViewController *emailVC = [EmailViewController new];
    if (0 == num)
    {
        emailVC.nice = YES;
    } else {
        emailVC.nice = NO;
    }
    [self.navigationController pushViewController:emailVC animated:YES];
}
- (void)tableViewHeadView
{
    CallMeHeadView *headView = [[CallMeHeadView alloc] initWithFrame:CGRectMake(0, 0, 375, 250)];
    self.tableView.tableHeaderView = headView;
    [headView release];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
